Skip to content

feat(starfish): send full block #6803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: consensus/feat/starfish-consensus
Choose a base branch
from

Conversation

VorobyevIlya
Copy link
Contributor

@VorobyevIlya VorobyevIlya commented May 8, 2025

Description of change

This PR introduces a full block structure, which contains a header and transactions.

Changes in network communications:
In streaming we now use SerialiedBlocks structure which contain serialization of a header and serializetion of transactions.
In synchronizer Functions fetching blocks are removed or changed to fetch headers. The only place where we still fetch blocks is in the commitSyncer.

Commit:
Certified commit contains blocks, CommittedSubDag contains only headers for now, blocks should be added later. In stake verification we use only headers, since it is enough.

CoreThreadDispatcher: a new command AddBlockHeaders was added. Several Fake/Mock dispatchers were merged into one.

Storage: we store now both headers and full blocks. If blocks are written to disk then their headers are written there too. There is a possibility to read blocks or only headers. Changes implemented both for mem_store and RocksDB.

Linearizer now operates with headers.

DagState and BlockManager:
DagState works with headers now since for building DAG only headers are important. However, we still store recent_blocks since we need to request blocks for fetching.
Functions such as accept block work with headers now. However, there can be situations when we already have data but the corresponding block header is not accepted yet. We can also have accepted header without data. Structures for storing such blocks and headers were added to BlockManager. They should be cleaned at some point, it is something to be done in future PRs.

Links to any relevant issues

closes #6707.

Type of change

Choose a type of change, and delete any options that are not relevant.

  • Enhancement (a non-breaking change which adds functionality)

How the change has been tested

  • Basic tests (linting, compilation, formatting, unit/integration tests)
  • Patch-specific tests (correctness, functionality coverage)

Change checklist

Tick the boxes that are relevant to your changes, and delete any items that are not.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

Release Notes

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented May 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
apps-backend ⬜️ Ignored (Inspect) Visit Preview May 27, 2025 5:04pm
apps-ui-kit ⬜️ Ignored (Inspect) Visit Preview May 27, 2025 5:04pm
rebased-explorer ⬜️ Ignored (Inspect) Visit Preview May 27, 2025 5:04pm
wallet-dashboard ⬜️ Ignored (Inspect) Visit Preview May 27, 2025 5:04pm

@VorobyevIlya VorobyevIlya self-assigned this May 8, 2025
@iota-ci iota-ci added consensus Issues related to the Core Consensus team core-protocol labels May 8, 2025
@VorobyevIlya VorobyevIlya force-pushed the consensus/feat/starfish/send-full-block branch from 7a9fb27 to c1e421a Compare May 9, 2025 19:32
@VorobyevIlya VorobyevIlya force-pushed the consensus/feat/starfish/send-full-block branch from 6ecd338 to 6c73112 Compare May 20, 2025 10:08
@piotrm50 piotrm50 force-pushed the consensus/feat/starfish-consensus branch from 6b470f7 to 3d6f76d Compare May 20, 2025 14:07
@github-actions github-actions bot added the ci Issues related to our CI pipeline label May 21, 2025
polinikita and others added 2 commits May 21, 2025 12:30
fix warnings

fmt

create add block headers command

it compiles!

fixing wrapper continues

fix decoupling header from transactions

decouple serialized bytes

fix typo

implement a wrapper around serialized header and transactions -- SerializedBlock (not finished)

implement write and read functions for blocks for RocksDB

fix test compilation

fix compilation errors

add a new struct VerifiedBlock
@VorobyevIlya VorobyevIlya force-pushed the consensus/feat/starfish/send-full-block branch from b6ffaef to be705ab Compare May 21, 2025 10:30
@VorobyevIlya VorobyevIlya force-pushed the consensus/feat/starfish/send-full-block branch from be705ab to 7c46133 Compare May 21, 2025 10:31
// TODO: dedup block verifications, here and with fetched blocks.
let signed_block: SignedBlockHeader =
bcs::from_bytes(&serialized_block).map_err(ConsensusError::MalformedBlock)?;
let verified_block = VerifiedBlock::try_from(serialized_block)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic should be
Serialized bytes -> signed block header + transaction data -> verify signature -> check correctness of data commitment -> verified block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it. Should we check the signature and commitment somewhere else?

suspended_block_headers: BTreeMap<BlockRef, SuspendedBlockHeader>,
/// Keeps full blocks for suspended block headers
suspended_blocks: BTreeMap<BlockRef, VerifiedBlock>,
// TODO: should it be here? need to discuss
Copy link
Member

@polinikita polinikita May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a brief explanation. Is it ever ever-growing set? If so, it might be too big at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there should be some eviction mechanism there. I will add to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@VorobyevIlya VorobyevIlya marked this pull request as ready for review May 27, 2025 14:42
@VorobyevIlya VorobyevIlya requested a review from a team as a code owner May 27, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Issues related to our CI pipeline consensus Issues related to the Core Consensus team core-protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants